package com.ruiyou.tb;

import android.app.Application;
import android.os.Handler;
import android.os.Message;

import com.tencent.smtt.sdk.QbSdk;

public class APPApplication extends Application {
    Handler handler;

    public APPApplication(Handler handler) {
        this.handler = handler;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        //搜集本地tbs内核信息并上报服务器，服务器返回结果决定使用哪个内核。
        QbSdk.PreInitCallback cb = new QbSdk.PreInitCallback() {
            @Override
            public void onViewInitFinished(boolean arg0) {
                //x5內核初始化完成的回调，为true表示x5内核加载成功，否则表示x5内核加载失败，会自动切换到系统内核。
                String s = arg0 ? "加载X5内核成功" : "加载内核失败";
                Message msg = new Message();
                msg.what = X5WebView.X5_MSG_WHAT_1;
                msg.getData().putString(X5WebView.X5_MSG_KEY_1, s);
                handler.sendMessage(msg);
            }

            @Override
            public void onCoreInitFinished() {
                // TODO Auto-generated method stub
            }
        };
        //x5内核初始化接口
        QbSdk.initX5Environment(getApplicationContext(), cb);
    }
}
